<?php
include_once(dirname(__FILE__).'/../autoload.php');


class Selenium_SessionTest extends Lib_SeleniumTestcase
{
	public function test_loginReloadPageAndLogout()
	{
        $this->open("/sweatshop/");
        $this->verifyTextsPresent(array('Login', 'Username', 'Password'));
        $this->fillForm("css=div#loginWindow", array(
           'username' => 'Dude',
           'password' => 'salasana'
        ));
        $this->focusAndClick("css=button:contains('Login')");
        $this->verifyTextPresent("Welcome Dude");
        $this->open("/sweatshop/");
        $this->focusAndClick("css=button:contains('Logout')");
        $this->verifyTextPresent('Session invalid or not started');
        $this->verifyTextPresent('Login');
    }

    public function test_tryToLoginWithWrongPassword()
    {
        $this->open('/sweatshop/');
        $this->verifyTextsPresent(array('Login', 'Username', 'Password'));
        $this->fillForm("css=div#loginWindow", array(
           'username' => 'Dude',
           'password' => 'ihanvääräsalasana'
        ));
        $this->focusAndClick("css=button:contains('Login')");
        $this->verifyTextPresent("Login failed, check username and password");
    }
}